import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
//将xml转成java bean
public class JaxbUnMarshal {

	public static void main(String[] args) {
		try {
			JAXBContext context = JAXBContext.newInstance(Book2.class);
			Unmarshaller m = context.createUnmarshaller();
			Book2 book = (Book2)m.unmarshal(new File("src/main/java/book.xml"));
			System.out.println(book.getId());
			System.out.println(book.getBookname());
			System.out.println(book.getAuthor());
			System.out.println(book.getPrice());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
